﻿<UserControl x:Class="gestadh45.wpf.UserControls.AdherentsUC.GestionAdherentsUC"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 	xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
	xmlns:uc="clr-namespace:gestadh45.wpf.UserControls"
 	xmlns:enum="clr-namespace:gestadh45.business.Enums;assembly=gestadh45.business"
 	xmlns:model="clr-namespace:gestadh45.model;assembly=gestadh45.model"
	xmlns:res="clr-namespace:gestadh45.wpf.Ressources"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
 	mc:Ignorable="d" 
 	d:DesignHeight="500" d:DesignWidth="600">
	<DockPanel Margin="5,5,5,5">
		<TextBlock DockPanel.Dock="Top"
			Text="{Binding Source={x:Static enum:CodesUC.GestionAdherents}, Converter={StaticResource ResourceKey=CodeUCToString}}"
			HorizontalAlignment="Stretch" Margin="0,5,0,10" 
			TextAlignment="Center" Style="{StaticResource ResourceKey=titreUC}" />

		<StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center">
			<Button ToolTip="{x:Static res:UI_Labels.Tltp_Enregistrer}" Margin="10,5,5,5" Style="{StaticResource ResourceKey=bigButton}"
						Command="{Binding Path=SaveItemCommand}">
				<Image Source="/gestadh45.wpf;component/Images/btn_save.png" />
			</Button>
		</StackPanel>
		
		<TextBox Name="tbxFiltre" Margin="0,0,0,10" DockPanel.Dock="Top" Width="300" HorizontalAlignment="Left">
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="TextChanged">
					<cmd:EventToCommand
								Command="{Binding Path=FilterCommand, Mode=OneWay}"
								CommandParameter="{Binding ElementName=tbxFiltre, Path=Text}" />
				</i:EventTrigger>
			</i:Interaction.Triggers>
		</TextBox>

		<ListBox Name="lbxItems" Width="300"
					ItemsSource="{Binding Path=Items}">
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="SelectionChanged">
					<cmd:EventToCommand 
						Command="{Binding Path=ShowDetailsCommand, Mode=OneWay}" 
						CommandParameter="{Binding ElementName=lbxItems, Path=SelectedItem}" />
				</i:EventTrigger>
			</i:Interaction.Triggers>

			<ListBox.ItemTemplate>
				<DataTemplate>
					<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
						<Image Name="imgSexe">
							<Image.Style>
								<Style TargetType="{x:Type Image}">
									<Setter Property="Source" Value="/gestadh45.wpf;component/Images/Man.png" />
									<Style.Triggers>
										<DataTrigger Binding="{Binding Path=Sexe}" Value="{x:Static model:Sexe.F}">
											<Setter Property="Source" Value="/gestadh45.wpf;component/Images/Woman.png" />
										</DataTrigger>
									</Style.Triggers>
								</Style>
							</Image.Style>
						</Image>
						
						<StackPanel Orientation="Vertical">
							<TextBlock Text="{Binding}" />
							<TextBlock>
								<TextBlock.Text>
									<MultiBinding StringFormat="{}{0:dd/MM/yyyy} ({1} an(s))">
										<Binding Path="DateNaissance" />
										<Binding Path="Age" />
									</MultiBinding>
								</TextBlock.Text>
							</TextBlock>
						</StackPanel>						
					</StackPanel>
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>

		<StackPanel DockPanel.Dock="Left" Orientation="Vertical" VerticalAlignment="Center" Margin="10,10,10,10">
			<uc:BtnAjouterEditerSupprimerUC 
				OrientationUC="Vertical"
				BtnAjouterVisibilite="Visible"
				BtnModifierVisibilite="Collapsed"
				BtnSupprimerVisibilite="Visible"
				CmdAjouter="{Binding Path=AddItemCommand}"
				CmdSupprimer="{Binding Path=DeleteItemCommand}"
				/>
			
			<Separator Margin="0,10,0,10" />

			<Button ToolTip="{x:Static res:UI_Labels.Tltp_CreerVoirInscription}" Margin="0,0,0,5" Style="{StaticResource ResourceKey=bigButton}"
						Command="{Binding Path=InscriptionCommand}">
				<Image Source="/gestadh45.wpf;component/Images/btn_inscrire.png" />
			</Button>

			<Button ToolTip="{x:Static res:UI_Labels.Tltp_DupliquerAdherent}" Margin="0,5,0,0"  Style="{StaticResource ResourceKey=bigButton}"
					Command="{Binding Path=CloneSelectedItemCommand}">
				<Image Source="/gestadh45.wpf;component/Images/btn_dupliquerAdherent.png" />
			</Button>
		</StackPanel>

		<ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True" DockPanel.Dock="Right">
			<StackPanel Margin="20,0,0,0" Orientation="Vertical">
				<StackPanel.Style>
					<Style TargetType="{x:Type StackPanel}">
						<Setter Property="IsEnabled" Value="True" />
					
						<Style.Triggers>
							<DataTrigger Binding="{Binding SelectedItem}" Value="{x:Null}">
								<Setter Property="IsEnabled" Value="False" />
							</DataTrigger>
						</Style.Triggers>
					</Style>
				</StackPanel.Style>
				
				<GroupBox Name="gbxIdentite" Header="{x:Static res:UI_Labels.Head_Identité}" Margin="0,0,0,10">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="100" />
							<ColumnDefinition Width="180" />
							<ColumnDefinition Width="150"  />
							<ColumnDefinition Width="180" />
						</Grid.ColumnDefinitions>
					
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition />
							<RowDefinition />
						</Grid.RowDefinitions>
					
						<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Nom}" />
						<TextBox Grid.Row="0" Grid.Column="1" Margin="0,5,0,0" 
						         CharacterCasing="Upper"
						         Text="{Binding Path=SelectedItem.Nom}" />
						
						<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Prenom}" />
						<TextBox Grid.Row="0" Grid.Column="3" Margin="0,5,0,0" 
						         Text="{Binding Path=SelectedItem.Prenom}" />
					
						<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_DateNaissance}" />
						<DatePicker Grid.Row="1" Grid.Column="1" Margin="0,5,0,0"
									DisplayDate="{Binding Path=SelectedItem.DateNaissance}" 
									SelectedDate="{Binding Path=SelectedItem.DateNaissance}"
									SelectedDateFormat="Short" />
					
						<TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Age}" />
						<TextBlock Grid.Row="1" Grid.Column="3" Margin="0,5,0,0" 
						           Text="{Binding Path=SelectedItem.Age, StringFormat='{}{0} an(s)'}" />
					
						<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Sexe}" />
						<ComboBox Grid.Row="2" Grid.Column="1" Width="50" HorizontalAlignment="Left" Margin="0,5,0,0"
						          ItemsSource="{Binding Path=Sexes}" 
						          SelectedItem="{Binding Path=SelectedItem.Sexe}">
							<i:Interaction.Triggers>
								<i:EventTrigger EventName="SelectionChanged">
									<cmd:EventToCommand	Command="{Binding Path=SaveItemCommand, Mode=OneWay}" />
								</i:EventTrigger>
							</i:Interaction.Triggers>
							
							<ComboBox.ItemTemplate>
								<DataTemplate>
									<TextBlock Text="{Binding Converter={StaticResource ResourceKey=SexeToString}}" />
								</DataTemplate>
							</ComboBox.ItemTemplate>
						</ComboBox>
					</Grid>
				</GroupBox>
				
				<GroupBox Name="gbxAdresse" Header="{x:Static res:UI_Labels.Head_Adresse}" Margin="0,0,0,10">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="50" />
							<ColumnDefinition Width="250" />
						</Grid.ColumnDefinitions>
					
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition />
						</Grid.RowDefinitions>
					
						<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Adresse}" />
						<TextBox Grid.Row="0" Grid.Column="1" Margin="0,5,0,0" 
						         Text="{Binding Path=SelectedItem.Adresse}" />
					
						<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Ville}" />
						<ComboBox Grid.Row="1" Grid.Column="1" Width="250" HorizontalAlignment="Left" Margin="0,5,0,0"
						          ItemsSource="{Binding Path=Villes}" 
						          SelectedItem="{Binding Path=SelectedItem.Ville}" />
					</Grid>		
				</GroupBox>
				
				<GroupBox Name="gbxContact" Header="{x:Static res:UI_Labels.Head_Contact}" Margin="0,0,0,10">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="50" />
							<ColumnDefinition Width="150" />
							<ColumnDefinition Width="30" />
							
							<ColumnDefinition Width="100" />
							<ColumnDefinition Width="250" />
							<ColumnDefinition Width="30" />
						</Grid.ColumnDefinitions>
						
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition />
							<RowDefinition />
						</Grid.RowDefinitions>
						
						<TextBlock Grid.Column="0" Grid.Row="0" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Telephone1}" />
						<xctk:MaskedTextBox Grid.Column="1" Grid.Row="0" Margin="0,5,0,0"
											Mask="00 00 00 00 00" 
											ValueDataType="{x:Type s:String}"
											Value="{Binding Path=SelectedItem.Telephone1}" />
						<Button Grid.Column="2" Grid.Row="0" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Telephone1}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/>
						
						<TextBlock Grid.Column="0" Grid.Row="1" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Telephone2}" />
						<xctk:MaskedTextBox Grid.Column="1" Grid.Row="1" Margin="0,5,0,0"
											Mask="00 00 00 00 00" 
											ValueDataType="{x:Type s:String}"
											Value="{Binding Path=SelectedItem.Telephone2}" />
						<Button Grid.Column="2" Grid.Row="1" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Telephone2}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/>
						
						<TextBlock Grid.Column="0" Grid.Row="2" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Telephone3}" />
						<xctk:MaskedTextBox Grid.Column="1" Grid.Row="2" Margin="0,5,0,0"
											Mask="00 00 00 00 00" 
											ValueDataType="{x:Type s:String}"
											Value="{Binding Path=SelectedItem.Telephone3}" />
						<Button Grid.Column="2" Grid.Row="2" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Telephone3}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/> 
					
						
						<TextBlock Grid.Column="3" Grid.Row="0" HorizontalAlignment="Right" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Mail1}" />
						<TextBox Grid.Column="4" Grid.Row="0" Margin="0,5,0,0" 
						         Text="{Binding Path=SelectedItem.Mail1}" />
						<Button Grid.Column="5" Grid.Row="0" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Mail1}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/>
						
						<TextBlock Grid.Column="3" Grid.Row="1" HorizontalAlignment="Right" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Mail2}" />
						<TextBox Grid.Column="4" Grid.Row="1" Margin="0,5,0,0" 
						         Text="{Binding Path=SelectedItem.Mail2}" />
						<Button Grid.Column="5" Grid.Row="1" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Mail2}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/> 
						
						<TextBlock Grid.Column="3" Grid.Row="2" HorizontalAlignment="Right" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Adherent_Mail3}" />
						<TextBox Grid.Column="4" Grid.Row="2" Margin="0,5,0,0" 
						         Text="{Binding Path=SelectedItem.Mail3}" />
						<Button Grid.Column="5" Grid.Row="2" Margin="0,5,0,0" 
						        Command="{Binding Path=CopyValueCommand}"
						        CommandParameter="{Binding Path=SelectedItem.Mail3}"
						        Style="{StaticResource ResourceKey=littleCopyButton}" 
						/> 
					</Grid>
				</GroupBox>
				
				<GroupBox Name="gbxDivers" Header="{x:Static res:UI_Labels.Head_Divers}" Margin="0,0,0,10">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="250" />
							<ColumnDefinition Width="20" />
							<ColumnDefinition Width="150" />
							<ColumnDefinition />
						</Grid.ColumnDefinitions>
					
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition />
						</Grid.RowDefinitions>
					
						<TextBox Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Margin="0,5,0,0"
						         TextWrapping="Wrap"
						         Text="{Binding Path=SelectedItem.Commentaire}" />
						
						<Separator Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" 
						           Width="2" HorizontalAlignment="Center"
						           Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
					
						<TextBlock Grid.Row="0" Grid.Column="2" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Label_DateCreation}" />
						<TextBlock Grid.Row="0" Grid.Column="3" Margin="0,5,0,0" 
						           Text="{Binding Path=SelectedItem.DateCreation, StringFormat='dd/MM/yyyy'}" />
						
						<TextBlock Grid.Row="1" Grid.Column="2" Margin="0,5,0,0" 
						           Text="{x:Static res:UI_Labels.Label_DateModification}" />
						<TextBlock Grid.Row="1" Grid.Column="3" Margin="0,5,0,0" 
						           Text="{Binding Path=SelectedItem.DateModification, StringFormat='dd/MM/yyyy'}" />
					</Grid>
				</GroupBox>
	
				<Separator Height="2" />
	
				<GroupBox Name="gbxStats" Header="{x:Static res:UI_Labels.Head_Stats}" Margin="0,0,0,10">
					<StackPanel Orientation="Vertical">
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="0,5,0,0" 
							           Text="{x:Static res:UI_Labels.Adherent_NbAdherents}" />
							<TextBlock Margin="0,5,0,0" 
							           Text="{Binding ElementName=lbxItems, Path=Items.Count}" />
						</StackPanel>
					</StackPanel>
				</GroupBox>
	
			</StackPanel>
		</ScrollViewer>
	</DockPanel>
</UserControl>